<template>
  <el-container direction="vertical" style="height:100%">
    <el-row class="padding_top_10" type="flex" align="middle">
      <el-col :span="5">
        <el-input
          placeholder="请输入搜索内容"
          prefix-icon="el-icon-search"
          v-model="txtsearch"
          clearable
        ></el-input>
      </el-col>
      <el-col :span="19" class="align-right">
        <el-button icon="el-icon-plus" @click="sys2edit()">新增</el-button>
      </el-col>
    </el-row>
    <el-main class="el-main_padding1">
      <el-table
        ref="table"
        v-loading="loading"
        border
        :data="tableData"
        stripe
        row-key="System_2_10"
        height="100%"
        default-expand-all
      >
        <el-table-column type="selection" width="40"> </el-table-column>
        <el-table-column type="index" width="40"> </el-table-column>
        <el-table-column prop="System_2_30" label="部门名称"> </el-table-column>
        <el-table-column prop="System_2_20" label="部门编号"> </el-table-column>
        <el-table-column prop="System_2_110" label="部门负责人">
        </el-table-column>
        <el-table-column label="操作" width="200px">
          <template slot-scope="scope">
            <el-button
              size="mini"
              icon="el-icon-edit"
              @click="sys2edit(scope.row)"
              >编辑</el-button
            >
            <el-button size="mini" icon="el-icon-delete">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-main>
    <!-- <el-footer class="main-footer ">
      <pagination :pageTotal="sys2Data.length" v-model="paginations">
      </pagination>
    </el-footer> -->
  </el-container>
</template>

<script>
import { System2 } from "@/api";
import sys2Edit from "./sys2Edit.vue";
export default {
  data() {
    return {
      loading: false,
      txtsearch: "",
      sys2Data: [],
      paginations: {}
    };
  },
  //外部属性
  props: {},
  //内部方法
  methods: {
    async initPage() {
      const loading = this.$loading({
        target: this.$refs.table.$el,
        lock: true,
        text: "加载中..."
      });
      this.sys2Data = await System2.get(this.txtsearch);
      this.$nextTick(() => {
        loading.close();
      });
    },
    sys2edit(row) {
      this.getsys2edit().show({ form: { ...row } });
    },
    //打开部门编辑
    getsys2edit() {
      let edit = this.$window(sys2Edit, "编辑部门");
      edit.$on("onSys2Save", (res, data) => {
        res.MsRbool && this.initPage();
      });
      return edit;
    }
  },
  //组件
  components: {},
  //初始化 异步加async await
  mounted() {
    this.initPage();
  },
  //计算属性
  computed: {
    //内存分页
    tableData() {
      let _data = this.sys2Data.getChildren("System_2_10", "System_2_70");
      // const { index = 1, size = 10 } = this.paginations;
      // _data = this.sys1Data.slice((index - 1) * size, size * index);
      //_data.getChildren("System_2_10", "System_2_70");
      return _data;
    }
  },
  //监视
  watch: {
    txtsearch() {
      this.initPage();
    }
  }
};
</script>

<style></style>
